/**
 * 中国手机号校验
 * @param {string} phone - 待校验号码
 * @param {boolean} [strict=false] - 是否严格模式（检查国际区号）
 * @returns {boolean}
 */
export function validateChineseMobile(phone, strict = false) {
	const reg = strict ?
		/^(?:(?:\+|00)86)?1[3-9]\d{9}$/ :
		/^1[3-9]\d{9}$/;

	// 基础格式校验
	if (!reg.test(phone)) return false;

	// 扩展校验：号段有效性
	const prefix = phone.slice(-11, -8); // 取第1-3位
	const validPrefix = [
		'130', '131', '132', '133', '134', '135', '136', '137', '138', '139',
		'145', '146', '147', '148', '149', '150', '151', '152', '153', '155',
		'156', '157', '158', '159', '162', '165', '166', '167', '170', '171',
		'172', '173', '174', '175', '176', '177', '178', '180', '181', '182',
		'183', '184', '185', '186', '187', '188', '189', '191', '192', '193',
		'194', '195', '196', '197', '198', '199'
	];

	return validPrefix.includes(prefix);
}

// 动态设置页面高度100%
export function calculateContentHeight(height) {
	if (!height && height != 0) {
		height = 84
	}
	const systemInfo = uni.getSystemInfoSync();

	// 计算可用高度（考虑状态栏、导航栏）
	const currHeight = systemInfo.windowHeight
	console.log(currHeight)
	return currHeight + 'px'
}

// 生成支付签名 
export function generatePaySign(appId, timeStamp, nonceStr, pack, key) {
	const stringSignTemp = `appId=${appId}&nonceStr=${nonceStr}&package=${pack}&signType=MD5&timeStamp=${timeStamp}&key=${key}`;
	return md5(stringSignTemp).toUpperCase();
}